home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
util1
/
kg_df105.zip
/
DF.8
next >
Wrap
Text File
|
1993-03-15
|
14KB
|
348 lines
;========================================================================== DF.8
; Program: Disk Free
; Version: 1.05
; Creator: Kevin O. Grover, INet: grover@cs.unlv.edu
; System: A86 V3.22 by Eric Isaacson
; Cre Date: 14 Dec 1988
; Mod Date: 15 Mar 1993
; Syntax: DF [d:] [?] [/s]
; History:
; ==============================================================================
; Date Vers Description of Modifications/Additions
; ----------- ---- -----------------------------------------------------------
; 14 Dec 1988 1.02 Original Version (as far as I can tell)
; 16 Feb 1991 1.03 Changed name to DF (from DI, because Norton used DI).
; Added comments, changed address in help, used tabs in help.
; Added Public Domain notice in Help message.
; 01 Oct 1991 1.04 Added /s option to enable statistics of the drive, they
; are not displayed by default
; 15 Mar 1993 1.05 Cleaned up text included in executable
; ==============================================================================
;
; Desc: This program displays the amount of avaliable, used, and free disk
; space in bytes. It also indicates the used and free space in terms
; of a percentage of the over all total disk space avaliable.
; In addition, sector and clustor information can be printed as
; an option.
;
; Note: Syntax for function 36h of Int 21H
; AH = 36h
; DL = dirve code (0=defualt, 1=A, 2=B, etc..)
;
; On Exit: if specified drive was vaild:
; AX = Sectors per cluster
; BX = number of available clusters
; CX = bytes per sector
; DX = clusters (allocation untis) per drive
; if the specified drive was invalid:
; AX = FFFFh
;
; ToDo: - Add /s (stats) option. If specified, display sector and cluster
; information. Otherwise, only display percentage and usage info.
;
; Bugs: - The parsing of the command line does not do many error checks
; (it is not very robust, but it is small)
; ==============================================================================
; ---------------------------------------------------------------------- Equates
Width EQU 14 ; Width of the field to print numbers in
Adjust EQU 10000 ; Used to compute and format the percentages
CR EQU 13 ; Carrage return
LF EQU 10 ; Line Feed
TAB EQU 9 ; Tab Character
; ----------------------------------------------------------------- Macro: Write
Write Macro
MOV AH, 9
LEA DX, #1
INT 21h
#EM
; ----------------------------------------------------------------- Macro: Print
Print Macro
MOV Ah, 2
MOV DL, #1
INT 21h
#EM
; ----------------------------------------------------------- Start of MAIN Code
Write Hello ; Print opening messages
MOV DI, 80h ; Check the command line for /? option for help!
MOV CH, 0
MOV CL, Byte Ptr [DI]
JCXZ SkipOptionCheck ; If zero, use the defualt drive
FindNextOption:
INC DI ; Point to the first byte
MOV AL, '/'
REPNE Scasb
JNE SkipOptionCheck
CMP Byte Ptr [DI], '?' ; Check for /? (help) option
JNE SkipHelp
Write Help ; Show help
MOV AX, 4C00h ; Terminate with a zero return code
INT 21h ; Do terminate
SkipHelp:
CMP Byte Ptr [DI], 's' ; check for /s (stats) option
JNE IllegalOption
MOV BYTE PTR ShowStatsFlg, 1 ; Turn Show stats on
JMP FindNextOption ; Look for next Option
IllegalOption:
Write IllOption ; Illegal Option
MOV AX, 4C01h ; Terminate with a return code of 1
INT 21h ; Do Terminate
; Start of Actual Program, i.e. No more option processing
SkipOptionCheck:
MOV Dl, [05Ch] ; Get the drive number from the FCB
MOV AH, 36h ; Function to get the disk info
INT 21h ; Get the info
CMP AX, 0FFFFh ; Test for an error reading the info
JNE NoError ; If error no error, go on
Write ErrorM ; OtherWise, Print and error message, and terminate
MOV AX, 4C01
INT 21h ; Terminate with return code 1
NoError:
MOV SecClus, AX ; Save the returned values.
MOV Free, BX
MOV ByteSec, CX
MOV Total, DX
XOR DX, DX
MUL ByteSec
MUL Total
MOV TotalBy, AX
MOV TotalBy+2, DX
MOV BX, Width
CALL LNum
Write TotalB
MOV AX, Free ; Calculate the percent of free space
MOV BX, Adjust ; Multiply by 10000 to give result in the
MUL BX ; form XXXX where it = XX.XX %
DIV Total ; Divide by the total
MOV Percent, AX ; Store the result
MOV AX, SecClus
XOR DX, DX
MUL ByteSec
MUL Free
MOV FreeBy, AX
MOV FreeBy+2, DX
MOV BX, Width
CALL LNum
Write FS ; Print the message for free space
MOV AX, Percent
CALL Per ; Print the percentage free
MOV AX, TotalBy
SUB AX, FreeBy
MOV DX, TotalBy+2
SBB DX, FreeBy+2
MOV BX, Width
CALL LNum
Write US ; Print the percent of used space
MOV AX, Adjust
SUB Ax, Percent ; Use Percent free to find percent used
CALL Per ; Call the percent output routine
CMP ShowStatsFlg, 0 ; Should we display statistics?
JE SkipStats ; If not, jump to end
Print 10 ; Leave a Blank Line
MOV AX, Total
MOV DX, 0
MOV BX, Width
CALL LNum
Write TCluster ; Print the total number of clusters.
MOV AX, Free
MOV DX, 0
MOV BX, Width
CALL LNum
Write Cluster ; Print the number of free clusters.
MOV AX, SecClus
MOV DX, 0
MOV BX, Width
CALL LNum
Write Sectors ; Print the number of sectors per cluster.
MOV AX, ByteSec
MOV DX, 0
MOV BX, Width
CALL LNum
Write BSector ; Print the number of bytes per sector.
SkipStats:
MOV AX, 4C00h
INT 21h ; Quit the program. (Return code = 0)
; -------------------------------------------------------------------------- Per
; Per takes the number in AX (xxx) and prints it as a percentage (xx.x%)
Per Proc Near
PUSH AX
MOV AH, 2
MOV DL, '('
INT 21h
POP AX
MOV Bl, 100
DIV BL ; Divide by ten to get the decimal part
PUSH AX ; Save the result on the stack
MOV DX, 0
MOV Ah, 0 ; Clear the remainder
MOV BX, 3 ; Field for the left part
CALL Lnum ; Print the quoitent (the percentage)
MOV Dl, '.' ; Print a decimal point
MOV Ah, 2
INT 21h
POP Ax ; Get the result back from the stack
MOV Al,Ah ; Put the remainder into AL
MOV Ah, 0 ; Clear AH leaving the decimal in AX
CMP Al, 9 ; Check for a one digit number
JA TwoDigits ; If not, jump ahead
PUSH AX ; If so, save some registers
PUSH DX
Print '0' ; If so, print a '0' to make it two digits.
POP DX
POP AX
TwoDigits:
MOV DX, 0
MOV BX, 1
CALL Lnum ; Print the decimal part
MOV DL, '%' ; Print a percentage sign
MOV AH, 2
INT 21h
MOV DL, ')'
INT 21h
MOV DL, 13
INT 21h
MOV DL, 10
INT 21h
RET
Per EndP
; ------------------------------------------------------------------------- LNum
; Prints a long integer (32 Bits) in DX:AX with a field width specified
; in BX. The number is right justified in the field width specified,
; with commas separating the characters where appropriate.
LNum Proc Near ;
PUSH AX ; Print a double word as an integer with a specified field width
PUSH BX ;
PUSH CX ; Number in DX:AX
PUSH DX ; Field Width in BX
PUSH SI ;
PUSH DI ;
PUSH BP ;
;
XCHG BP,DX ; Save DX in BP
MOV DI, BX ; Save the field width in DI
MOV BX, 10 ; MOV BX, 10 - The base to divide by
MOV CX, 0 ; Clear the count
MOV SI, 0 ;
MoreL: ;
;
CMP BP, 0 ; See if the MSW is zero
JZ OneWord ; JZ OneWord (YES)
XCHG BP,AX ; The high word is not zero!, save low word in BP
XOR DX,DX ; Make DX zero
DIV BX ; Divide AX by the base (Quotient in AX, remainder in DX)
XCHG BP,AX ; Get Old Low word backin AX, and put this quotient into BP
DIV BX ; Divide by the base again
OR DL, '0' ; Convert DL to ASCII (See Note)
PUSH DX ; Store it in memory ont the stack
INC CX ; Increment the count
INC SI ;
CMP SI, 3 ;
JNE MoreL ;
;
MOV DL, ',' ;
PUSH DX ;
INC CX ;
MOV SI, 0 ;
JMP MoreL ; (Go and do the next Number)
OneWord: ;
XOR DX,DX ; Clear DX (of the last remainder)
DIV BX ; Divide by the base
OR DL, '0' ; Convert the remainder to ASCII
PUSH DX ; Store it in on the stack
INC CX ; Increment the count
CMP AX, 0 ;
JE AllDone ;
INC SI ;
CMP SI, 3 ;
JNE OneWord ;
MOV DL, ',' ;
PUSH DX ;
INC CX ;
MOV SI, 0 ;
JMP OneWord ;
AllDone: ;
;
CMP CX, DI ;
JAE Ok ;
NEG CX ;
ADD CX, DI ;
MOV DL, ' ' ;
Pad: PUSH DX ;
LOOP Pad ;
MOV CX, DI ;
Ok: ;
MOV AH, 2 ;
PrintIt: POP DX ;
INT 21h ;
LOOP PrintIt ;
;
;
POP BP ; Retore the registers used
POP DI ;
POP SI ;
POP DX ;
POP CX ;
POP BX ;
POP AX ;
RET ; Return to the caller
LNum EndP
; ------------------------------------------------------------------------- Data
TotalBy DW ?,? ; Total Bytes on the disk
FreeBy DW ?,? ; Number of Free bytes
Total DW ? ; Total Clusters on the disk
Free DW ? ; Number of Free Clusters
SecClus DW ? ; Number of Sectors per clustor
ByteSec DW ? ; Number of Bytes per sector
Percent DW ? ; Used to hold percentage free/used.
ShowStatsFlg DB 0 ; Flag to show statics about drive (def=FALSE)
Hello DB 'DF-Disk Free V1.05, 1988/1993, Kevin Grover [DF /? for help]',CR,LF,LF,'$'
Help DB 'Kevin O. Grover, grover@isri.unlv.edu, CServe: 73627,1677', CR, LF, LF
DB 'DF displays the number of total/free/used bytes on a disk and the',CR,LF
DB 'precentage of free and used bytes. In addition, specifics of the',CR,LF
DB 'drive can be displayed as an option',CR,LF,LF
IllOption DB 'Usage: DF [d:] [/?] [/s]',CR,LF,'$'
TotalB DB ' bytes total disk space',CR,LF,'$'
FS DB ' bytes free $'
US DB ' bytes used $'
TCluster DB ' Total clusters',CR,LF,'$'
Cluster DB ' Available clusters',CR,LF,'$'
Sectors DB ' Sectors per cluster',CR,LF,'$'
BSector DB ' Bytes per sector',CR,LF,'$'
ErrorM DB TAB,'Invalid drive specification!',LF,'$'